import axios from "axios";

export let get_list = () =>{
    return (dispatch)=>{
        axios.get("/list").then(res=>{
            console.log(res);
            dispatch({
                type:"GET_LIST",
                payload:res.data
            })
        })
    }
}

export let set_listChildren = (key) =>{
    return{
        type:"SET_LISTCHILREN",
        payload:key
    }
}   

export let get_table = () =>{
    return async(dispatch)=>{
        let data = await axios.get("/table")
        dispatch({
            type:"GET_TABLE",
            payload:data.data.data
        })
    }
}

export let set_slice_data = (page,pageSize)=>{
    return {
        type:"SET_SLICE_DATA",
        payload:{
            page,
            pageSize
        }
    }
}

export let del_tableData = (record)=>{
    return {
        type:"DEL_TABLEDATA",
        payload:record
    }
}

export let filter_tableData = (state)=>{
    if (state === "全部") {
        return get_table()
    }else{
        return {
            type:"FILTER_DATA",
            payload:state
        }
    }  
}

export let add_table_data = (obj)=>{
    return {
        type:"ADD_TABLEDATA",
        payload:obj
    }
}

export let edit_table_data = (obj)=>{
    return {
        type:"EDIT_TABLEDATA",
        payload:obj
    }
}

export let low_high_data = ()=>{
    return {
        type:"LOW_HIGH_DATA",
        // payload:obj
    }
}

export let gigh_low_data = ()=>{
    return {
        type:"HIGH_LOW_DATA",
        // payload:obj
    }
}

export let seach_data = (str)=>{
    return {
        type:"SEACH_DATA",
        payload:str
    }
}

